#ifndef H_RCGD_DIAG_H
#define H_RCGD_DIAG_H

/*=================================================================*/
/*                         DEFINE                                  */
/*=================================================================*/

/*=================================================================*/
/*                           DIAG.C                                */
/*=================================================================*/


#define EFC_UPPER_LIMIT		64535
#define EFC_LOWER_LIMIT		1000


#define EFC_RB_UPPER_LIMIT		(20000 - 1000)
#define EFC_RB_LOWER_LIMIT		(-20000 + 1000)


typedef struct Diag_S{
    char    EB;
    char 	EB_LOCK;
    char    OCXO;
    int		power_fault_counter;
    int		power_good_counter;
    char    POWER;
    char    EFC;
    char	PPS;
    char	PLL;
    char	ESYNC;
    char	DUAL_RX;
    char	DUAL_TX;
    char	DUAL_RX_CRC;
    char	DUAL_EXIST;
    char	DUAL_TEST;
    char	DUAL_STEP;
    int		DUAL_TIMEOUT;
    int		DUAL_FAIL_LED;
    char	dDAC;
    char	COUNTER;
    char	DELETION_COUNTER;
	char	TEMPERATURE;
	char	SYSTEM;
	char	OSC;
	char	RTC;
	char	EJT;
	char	TRACE_10M_COUNTER;

	char 	Monitor1PPSCounter;

    char	PPS_ALARM_FLAG;
    char	PPS_FAULT_FLAG;
    int		PPS_SWITCH_COUNTER;
    int		PPS_WatchCounter;
    char	PPS_RECOVERY_FLAG;

    int 	Watch1PPSCounter;

	/* HW Fail */
    char	_10MHz,_FAULT;
    char	PP2S_OFFSET;

	char	_10MHz_GoodCounter;
	char	RB;

	int 	TFOM;
	
	int		AntennaFaultCounter;
	int		EjtOKCounter;
	int		DualRxFailCounter;
	int		DualRxFailHopeless;
	int		DualRxChkOKCounter;
	
	int		me_exist_ok_counter;
	int		me_exist_nok_counter;
	int		you_exist_ok_counter;
	int		you_exist_nok_counter;
	
	char	i_exist;
	char	u_exist;
	
} Diag_;



typedef struct{
	char rtc;
	char osc;
	char power;
} manual_diag_;
/*=================================================================*/
/*                       Function Declaration                      */
/*=================================================================*/

extern Diag_	DIAG;
extern Diag_	PrevDIAG;
extern OP_		PrevOperation;


extern char		STATUS_Warmup;




extern void Diagnose();
extern void MonitorSTATUS();
extern void MyMonitorSTATUSForDebug();
extern void MyMonitorSTATUSout();

extern void Init_DIAG();


extern manual_diag_	manual_diag;
//extern char once_receiver_detect;
extern int last_init_eb;


extern int PrintON;

typedef struct{
	char EB;
} HEALTH_;

extern HEALTH_ HEALTH;

#endif
